<script>
	import * as types from 'store/mutations_types'
	import * as API from 'server/getData'
	export default {
		onLaunch: function() {
			uni.getStorage({
				key: 'token',
				success: async (res) => {
					// 获取本地存储上的token到store
					this.$store.commit(types.TOKEN, res.data)
					await this.$store.dispatch('login_user')
				},
				fail: (e) => {
					uni.showModal({
						title: '未登录',
						content: '您未登录，需要登录后才能继续',
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								uni.reLaunch({url: '/pages/users/login'})
							}
						}
					})
				}
			})
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>


<style>
	/* uni.css - 通用组件、模板样式库，可以当作一套ui库应用 */
	@import './common/uni.css';
	@import './common/iconfont.css';

	/* 以下样式用于 hello uni-app 演示所需 */
	page {
		background-color: #F4F5F6;
		height: 100%;
		font-size: 28upx;
		line-height: 1.8;
	}

</style>
